package com.ly.ssh.service.impl;

import com.ly.ssh.dao.AddressDao;
import com.ly.ssh.entity.Address;
import com.ly.ssh.entity.Person;
import com.ly.ssh.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by XRom
 * On 11/16/2017.11:58 PM
 */
@Service
public class AddressServiceImpl implements AddressService {

    @Autowired(required = true)
    private AddressDao addressDao;

    @Override
    public Integer saveAddress() {
        Person person = new Person();
        person.setUsername("XRog");
        person.setPhone("18381005946");
        person.setRemark("this is XRog");
        Address a =new Address();
        a.setAddr("a");
        a.setPerson(person);
        return addressDao.save(a);
    }
    @Transactional
    public List<Address> getAll(){
        return addressDao.findAll();
    }
}
